package org.alex.netShop.beans;

import java.awt.List;
import java.util.LinkedList;

import org.alex.netShop.enums.Country;
import org.alex.netShop.enums.Gender;
import org.alex.netShop.interfaces.Customer;
import org.alex.netShop.interfaces.Customers;
import org.alex.netShop.interfaces.Purchase;
import org.alex.netShop.interfaces.User;
import org.alex.netShop.interfaces.Users;
import org.apache.tapestry5.Link;





public class UserBean implements User
{
	
	private String userName;
	private String password;
	private Gender gender;
	private boolean subscribe;
	private String email;
	private Country country;
	private double age;
	
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#getUserName()
	 */
	public String getUserName() {
		return userName;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setUserName(java.lang.String)
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#getPassword()
	 */
	public String getPassword() {
		return password;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setPassword(java.lang.String)
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#getGender()
	 */
	public Gender getGender() {
		return gender;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setGender(org.alex.netShop.enums.Gender)
	 */
	public void setGender(Gender gender) {
		this.gender = gender;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#isSubscribe()
	 */
	public boolean isSubscribe() {
		return subscribe;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setSubscribe(boolean)
	 */
	public void setSubscribe(boolean subscribe) {
		this.subscribe = subscribe;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#getEmail()
	 */
	public String getEmail() {
		return email;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setEmail(java.lang.String)
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#getCountry()
	 */
	public Country getCountry() {
		return country;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setCountry(org.alex.netShop.enums.Country)
	 */
	public void setCountry(Country country) {
		this.country = country;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#getAge()
	 */
	public double getAge() {
		return age;
	}
	/* (non-Javadoc)
	 * @see org.alex.netShop.beans.User#setAge(double)
	 */
	public void setAge(double age) {
		this.age = age;
	}
	
	public void executeUserCreation(String userName, String password, Gender gender, boolean subscribe, String email, Country country, double age, Users users, Customers customers) {
		// Kreiranje novog user-a
		this.setUserName(userName);
		this.setPassword(password);
		this.setGender(gender);
		this.setSubscribe(subscribe);
		this.setEmail(email);
		this.setCountry(country);
		this.setAge(age);
		// Pamcenje u UsersBean-u
		users.save(this);
		// Istu stvar zapamtiti i u customera jer je taj user customer
	    Customer customerBean = new CustomerBean();
	    customerBean.setPurchase(new LinkedList<Purchase>());
	    customerBean.setName(userName);
		customers.save(customerBean);
}
	
	

	

}
